
typedef struct genericList
{
    void *data;
    struct genericList *sgt;
}gl;


typedef struct genericCola
{
    void *data;
    struct genericList *sgt;
    struct genericCola *ant;
}gc;


typedef struct genericListWithSublist
{
    void *data;
    struct genericListWithSublist *content;
    struct genericListWithSublist *sgt;
}glws;


void addToList(gl *list, void *data);
void deleteToList(gl *list, void *data);
void deleteToListByPosition(gl *list, int pos);
void* memoryReserve(void *dato);
void addToListWithSublist(glws *list, void *data, glws *sublist);




void addToListWithSublist(glws *list, void *data, glws *sublist)
{
    if (list->data == NULL)
    {
        list->data = data;
	list->content = sublist;        
        list->sgt = NULL;
    }
    else
    {
        glws *aux = list;
        while (aux->sgt!=NULL)
        {
            aux = aux->sgt;                                                                                                                                          
        }
        glws *newNode = (glws*) malloc(sizeof(glws));
        newNode->data = data;
	newNode->content = sublist;
        newNode->sgt = NULL;
        aux->sgt = newNode;
    }
}


void addToList(gl *list, void *data)
{
    if (list->data == NULL)
    {
        list->data = data;
        list->sgt = NULL;
    }
    else
    {
        gl *aux = list;
        while (aux->sgt!=NULL)
        {
            aux = aux->sgt;
        }
        gl *newNode = (gl*) malloc(sizeof(gl));
        newNode->data = data;
        newNode->sgt = NULL;
        aux->sgt = newNode;
    }
}


void addListToList(gl *list, gl *listToAdd)
{
    int i = 0;
    gl *q = listToAdd;
    for(i=0;q!=NULL;i++)
    {
      addToList(list,q->data);
      q = q->sgt;
    }
}

void deleteToList(gl *list, void *data)
{
    gl *aux = list;
    if (aux!=NULL)
    {
        if (aux->data!=data)
        {
            while (aux->sgt!=NULL && aux->sgt->data!=data)
            {
                aux = aux->sgt;
            }
            if (aux->sgt != NULL)
            {
                gl *dispose;
                dispose = aux->sgt;
                aux->sgt = aux->sgt->sgt;
                free(dispose);
            }
        }
        else
            *list = *aux->sgt;
    }
}

void deleteListToList(gl *list, gl *listToDelete)
{
    int i = 0;
    gl *q = listToDelete;
    for(i=0;q!=NULL;i++)
    {
      gl *aux = q->sgt;
      deleteToList(list,q->data);
      q = aux;
    }
}

void deleteToListByPosition(gl *list, int pos)
{
    gl *aux = list;
    gl *ant = list;
    int i = 0;
    if (aux!=NULL)
    {
        for (i = 0;aux != NULL && i < pos; i++)
        {
            aux = aux->sgt;
            if (i!=0)
                ant = ant->sgt;
        }
        if (i!=0)
        {
            if (aux!=NULL)
            {
                gl *dispose;
                dispose = aux;
                ant->sgt = aux->sgt;
                free(dispose);
            }
        }
        else
            *list = *aux->sgt;

    }
}

void* memoryReserve(void *dato)
{
    dato = (void*) malloc(sizeof(void));
}



void addToCola(gc *list, void *data)
{
}